/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.feiyue.basic.reader.dao;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import com.feiyue.basic.reader.pojo.Setting;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class SettingDao extends Dao {
	private static final String COMPERE = "setting";

	public SettingDao(Context paramContext) {
		super(paramContext);
		this.db.setTableName("setting");
	}

	private List<Setting> getList(Cursor paramCursor) {
		ArrayList localArrayList = new ArrayList();
		paramCursor.moveToFirst();
		while (true) {
			if (paramCursor.isAfterLast()) {
				paramCursor.close();
				return localArrayList;
			}
			Setting localSetting = new Setting();
			localSetting.setId(paramCursor.getLong(0));
			localSetting.setDayType(paramCursor.getInt(1));
			localSetting.setFontSize(paramCursor.getInt(2));
			localSetting.setTextNum(paramCursor.getInt(3));
			localSetting.setLight(paramCursor.getFloat(4));
			localSetting.setBg(paramCursor.getInt(5));
			localArrayList.add(localSetting);
			paramCursor.moveToNext();
		}
	}

	public void delete(long paramLong) {
		this.db.delete(paramLong);
	}

	public String getApi(String paramString, long paramLong) {
		return paramString + "_" + paramLong;
	}

	public List<Setting> getList() {
		return getList(this.db.query(new String[] { "id", "dayType",
				"fontSize", "textNum", "light", "bg" }, null, null, null, null,
				null));
	}

	public List<Setting> getList(long paramLong) {
		DBHelper localDBHelper = this.db;
		String[] arrayOfString1 = { "id", "dayType", "fontSize", "textNum",
				"light", "bg" };
		String[] arrayOfString2 = new String[1];
		arrayOfString2[0] = String.valueOf(paramLong);
		return getList(localDBHelper.query(arrayOfString1, "id = ?",
				arrayOfString2, null, null, null));
	}

	public void save(Setting paramSetting) {
		List localList = getList(paramSetting.getId());
		ContentValues localContentValues = new ContentValues();
		if (localList.size() == 0) {
			localContentValues.put("dayType",
					Integer.valueOf(paramSetting.getDayType()));
			localContentValues.put("fontSize",
					Integer.valueOf(paramSetting.getFontSize()));
			localContentValues.put("textNum",
					Integer.valueOf(paramSetting.getTextNum()));
			localContentValues.put("light",
					Float.valueOf(paramSetting.getLight()));
			localContentValues.put("bg", Integer.valueOf(paramSetting.getBg()));
			this.db.insert(localContentValues);
			return;
		}
		localContentValues.put("id", Long.valueOf(paramSetting.getId()));
		localContentValues.put("dayType",
				Integer.valueOf(paramSetting.getDayType()));
		localContentValues.put("fontSize",
				Integer.valueOf(paramSetting.getFontSize()));
		localContentValues.put("textNum",
				Integer.valueOf(paramSetting.getTextNum()));
		localContentValues.put("light", Float.valueOf(paramSetting.getLight()));
		localContentValues.put("bg", Integer.valueOf(paramSetting.getBg()));
		this.db.update(paramSetting.getId(), localContentValues);
	}

	public void save(List<Setting> paramList) {
		Iterator localIterator = paramList.iterator();
		while (true) {
			if (!(localIterator.hasNext()))
				return;
			save((Setting) localIterator.next());
		}
	}
}